/*
 * @Author: @yzcheng
 * @Date: 2021-02-26 18:45:53
 * @Version: 1.0
 * @LastEditors: @yzcheng
 * @Description:
 * @LastEditTime: 2021-03-27 14:53:58
 */
import request from '@/utils/request'
import { CHECC_API_PROCESS } from '@/constants/proxy'

/**
 *  下载文件
 *
 * @export
 * @param {*} params
 * @return {*}
 */
export function flowDownload(procDefId) {
  return request.get(CHECC_API_PROCESS + '/act/rep/export', {
    params: {
      proInsId: 'null',
      procDefId,
      resType: 'bpmn',
    },
  })
}
/**
 *  预览
 *
 * @export
 * @param {*} params
 * @return {*}
 */
export function flowView(procDefId) {
  return request({
    url: CHECC_API_PROCESS + `/act/rep/view`,
    method: 'get',
    params: { proInsId: '', procDefId, resType: 'bpmn' },
  })
}
/**
 * 部署流程
 *
 * @export
 * @param {*} id
 * @return {*}
 */
export function deploymentProcess(id) {
  return request({
    url: CHECC_API_PROCESS + `/act/rep/deployment/${id}`,
    method: 'post',
    data: {},
  })
}
/**
 *  根据流程定义文件id删除部署的流程
 *
 * @export
 * @param {*} id
 * @return {*}
 */
export function deleteByFlowId(id) {
  return request({
    url: CHECC_API_PROCESS + `/act/rep/delete`,
    method: 'delete',
    params: { deploymentId: id },
  })
}
/**
 *  根据文件id挂起全部部署的流程
 *
 * @export
 * @param {*} id
 * @return {*}
 */
export function suspendAllById({ procDefId, suspend }) {
  return request({
    url: CHECC_API_PROCESS + `/act/rep/suspendById`,
    method: 'get',
    params: { procDefId, suspend },
  })
}

export function getFlowDefineList(data, { pageNum, pageSize }) {
  return request({
    url: CHECC_API_PROCESS + `/act/rep/page?pageNum=${pageNum}&pageSize=${pageSize}`,
    method: 'post',
    data,
  })
}
